package org.jadestudio.dsdown.service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.jadestudio.dsdown.dao.GameManageDao;
import org.jadestudio.dsdown.dao.ManageLoginDao;
import org.jadestudio.dsdown.entity.ManageAdminLogin;
import org.jadestudio.dsdown.entity.ManageGame;
import org.jadestudio.dsdown.entity.ManageGameDownloads;
import org.jadestudio.dsdown.entity.ManageGamePic;
import org.jadestudio.dsdown.entity.ManageGamePublishCompany;
import org.jadestudio.dsdown.entity.ManageGamePurchase;
import org.jadestudio.dsdown.entity.ManageHomePagePicCfg;
import org.jadestudio.dsdown.util.SysInfo;
import org.springframework.stereotype.Component;

@Component
public class GameManageService {
	@Resource
	GameManageDao gameManageDao;

	
	/**
	 * 游戏发行厂商显示（带分页）
	 * @param manageGamePublishCompany
	 */
	public List publishCompanyQueryByPaging(Map queryMap){
		try {
			return gameManageDao.publishCompanyQuery(queryMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	/**
	 * 游戏发行厂商数量查询
	 * @param queryMap
	 * @return
	 */
	public int publishCompanyCountQuery(Map queryMap){
		try {
			return gameManageDao.publishCompanyCountQuery(queryMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}
	/**
	 * 游戏发行厂商新增
	 * @param manageGamePublishCompany
	 */
	public void publishCompanyAdd(ManageGamePublishCompany manageGamePublishCompany){
		try {
			gameManageDao.publishCompanyAdd(manageGamePublishCompany);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	/**
	 * 游戏发行厂商修改
	 * @param manageGamePublishCompany
	 */
	public int publishCompanyModify(ManageGamePublishCompany manageGamePublishCompany){
		try {
			return gameManageDao.publishCompanyModify(manageGamePublishCompany);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}
	/**
	 * 游戏发行厂商显示ById
	 * 
	 */
	public Map publishCompanyQueryById(String id){
		try {
			return (Map)gameManageDao.publishCompanyQueryById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	/**
	 * 游戏发行厂商删除ById
	 * 
	 */
	public int publishCompanyDeleteById(String id){
		try {
			return gameManageDao.publishCompanyDeleteById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}
	
	/**
	 * 游戏图鉴类型查看
	 * @return
	 */
	public List gameTypeQuery(){
		try {
			return gameManageDao.gameTypeQuery();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 游戏平台数据查看
	 * @return
	 */
	public List gamePlatFormQuery(){
		try {
			return gameManageDao.gamePlatFormQuery();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 模糊查询游戏发行厂商
	 * @return
	 */
	public List gamePublishCompanyQuery(String gamePublishCompanyName){
		try {
			return gameManageDao.gamePublishCompanyQuery(gamePublishCompanyName);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
		
		
	}
	
	/**
	 * 图鉴插入
	 * @param manageGame
	 * @return
	 */
	public int gameInsert(ManageGame manageGame){
		try {
			gameManageDao.gameInsert(manageGame);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴更新
	 * @param manageGame
	 * @return
	 */
	public int gameUpdate(ManageGame manageGame){
		try {
			gameManageDao.gameModify(manageGame);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴删除BYID
	 * @return
	 */
	public int gameDeleteById(String gameId){
		try {
			gameManageDao.gameDelete(gameId);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴下载地址插入
	 * @return
	 */
	public int gameDownloadsInsert(ManageGameDownloads manageGameDownloads){
		try {
			gameManageDao.gameDownloadsInsert(manageGameDownloads);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴下载地址更新
	 * @return
	 */
	public int gameDownloadsUpdate(ManageGameDownloads manageGameDownloads){
		try {
			gameManageDao.gameDownloadsUpdate(manageGameDownloads);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
		
	}
	
	/**
	 * 图鉴下载地址删除
	 * @return
	 */
	public int gameDownloadsDelete(String gameId){
		try {
			gameManageDao.gameDownloadsDelete(gameId);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	
	/**
	 * 图鉴购买地址插入
	 * @return
	 */
	public int gamePurchaseInsert(ManageGamePurchase manageGamePurchase){
		try {
			gameManageDao.gamePurchaseInsert(manageGamePurchase);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
		
	}
	
	/**
	 * 图鉴购买地址更新
	 * @return
	 */
	public int gamePurchaseUpdate(ManageGamePurchase manageGamePurchase){
		try {
			gameManageDao.gamePurchaseUpdate(manageGamePurchase);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴购买地址删除
	 * @return
	 */
	public int gamePurchaseDelete(String gameId){
		try {
			gameManageDao.gamePurchaseDelete(gameId);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴图片地址插入
	 * @return
	 */
	public int gamePicInsert(ManageGamePic manageGamePic){
		try {
			gameManageDao.gamePicInsert(manageGamePic);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
		
	}
	
	/**
	 * 图鉴图片地址更新
	 * @return
	 */
	public int gamePicUpdate(ManageGamePic manageGamePic){
		try {
			gameManageDao.gamePicUpdate(manageGamePic);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
		
	}
	
	/**
	 * 图鉴图片地址删除
	 * @return
	 */
	public int gamePicDelete(String gameId){
		try {
			gameManageDao.gamePicDelete(gameId);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 图鉴显示（带分页）
	 * @param queryMap
	 * @return
	 */
	public List gameQuery(Map queryMap){
			try {
				return gameManageDao.gameQuery(queryMap);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
	}
	
	/**
	 * 图鉴数量显示
	 * @param queryMap
	 * @return
	 */
	public int gameCountQuery(Map queryMap){
			try {
				return gameManageDao.gameCountQuery(queryMap);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return 0;
	}
	
	/**
	 * 图鉴显示ById
	 * 
	 */
	public Map gameQueryById(String id){
		try {
			return (Map)gameManageDao.gameQueryById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 图鉴下载地址查询BYGameId
	 * @param id
	 * @return
	 */
	public List gameDownloadsQueryByGameId(String gameId){
		try {
			return (List)gameManageDao.gameDownloadsQueryByGameId(gameId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 图鉴购买地址查询BYGameId
	 * @param id
	 * @return
	 */
	public List gamePurchaseQueryByGameId(String gameId){
		try {
			return (List)gameManageDao.gamePurchaseQueryByGameId(gameId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 图鉴图片上传地址查询BYGameId
	 * @param id
	 * @return
	 */
	public List gamePicQueryByGameId(String gameId){
		try {
			return (List)gameManageDao.gamePicQueryByGameId(gameId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	
	/**
	 * 主页大图配置查询
	 * @param queryMap
	 * @return
	 * @throws SQLException
	 */
	public List<Map> homePagePicCfgQuery(){
		try{
			return gameManageDao.homePagePicCfgQuery();
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 主页大图记录更新
	 * @param queryMap
	 * @return
	 * @throws SQLException
	 */
	public int homePagePicCfgInsert(ManageHomePagePicCfg homePagePicCfg) throws SQLException{
		try{
			gameManageDao.homePagePicCfgInsert(homePagePicCfg);
			return 1;
		}catch(Exception e){
			e.printStackTrace();
		}
		return 0;
	}
	
	/**
	 * 主页大图记录删除
	 * @param homePagePicCfg
	 * @return
	 * @throws SQLException
	 */
	public int homePagePicCfgDelete() throws SQLException{
		try{
			gameManageDao.homePagePicCfgDelete();
			return 1;
		}catch(Exception e){
			e.printStackTrace();
		}
		return 0;
	}
	
	
	/**
	 * 服务器配置查询
	 * @param queryMap
	 * @return
	 * @throws SQLException
	 */
	public List<Map> serverCfgQuery(){
		try{
			return gameManageDao.serverCfgQuery();
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}
	
	
	/**
	 * 服务器配置更新
	 * @param queryMap
	 * @return
	 * @throws SQLException
	 */
	public int serverCfgUpdate(Map map){
		try{
			 gameManageDao.serverCfgUpdate(map);
			 return 0;
		}catch(Exception e){
			e.printStackTrace();
		}
		return 0;
	}
	
	
	
	
	
	
}
